﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GestionRecaudos
{
    public partial class FrmRpt_CartulinasDevueltas : Form
    {
        public FrmRpt_CartulinasDevueltas()
        {
            InitializeComponent();
        }

        private void FrmRpt_CartulinasDevueltas_Load(object sender, EventArgs e)
        {
            this.FechaIniDateTimePicker.Value = DateTime.Now;
            this.FechaFinDateTimePicker.Value = DateTime.Now;
        }

        private void FechaIniDateTimePicker_Leave(object sender, EventArgs e)
        {
            this.FechaFinDateTimePicker.Value = this.FechaIniDateTimePicker.Value;
        }

        private void imprimirButton_Click(object sender, EventArgs e)
        {
            try
            {
                string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[Utils.get().getValorParametro("SeccionAppConfigGestionRecaudosConnectionString")].ConnectionString;
                DataTable table = new DataTable();
                table.TableName = this.tittle.Text;
                using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connectionString))
                {
                    conn.Open();
                    System.Data.SqlClient.SqlCommand command = conn.CreateCommand();
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "[spRpt_CartulinasDevueltas]";
                    command.Parameters.Add(new System.Data.SqlClient.SqlParameter("@OP", "Imprimir"));
                    command.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Fecha_Ini", this.FechaIniDateTimePicker.Value));
                    command.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Fecha_Fin", this.FechaFinDateTimePicker.Value));
                    table.Load(command.ExecuteReader());
                    conn.Close();
                }
                Utils.get().exportar(table, true);
            }
            catch (Exception ex)
            {
                MessageException.show(ex);
            }
        }
    }
}
